﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Udish udish = new Udish("金士顿64G");
            udish.Info();

            MHB mhb = new MHB("骇客神条");
            mhb.Info();
            Console.WriteLine();
            Computer comparer = new Computer("惠普");

            comparer.Starting();
            comparer.usb1 = udish;
            comparer.usb2 = mhb;
            comparer.Usb1();
            comparer.Usb2();
            comparer.Shutdown();

            Console.ReadLine();
        }
    }

    class Udish : Father, IUSB
    {
        public Udish(string name) : base()
        {
            this.name = name;
        }
        public void Read()
        {
            Console.WriteLine("{0}写入数据中...", this.name);
        }

        public void Write()
        {
            Console.WriteLine("{0}读取数据中...", this.name);
        }
    }
    class MHB : Father, IUSB
    {
        public MHB(string name) : base()
        {
            this.name = name;
        }
        public void Read()
        {
            Console.WriteLine("{0}写入数据中...", this.name);
        }

        public void Write()
        {
            Console.WriteLine("{0}读取数据中...", this.name);
        }
    }
    class Father
    {
        public string name { get; set; }

        public Father() { }
        public Father(string name)
        {
            this.name = name;
        }
        public void Info()
        {
            Console.WriteLine("{0}", this.name);
        }
    }
    class Computer
    {
        public string Name { get; set; }

        public IUSB usb1 { get; set; }
        public IUSB usb2 { get; set; }

        public Computer(string name)
        {
            this.Name = name;
        }

        public void Starting()
        {
            Console.WriteLine("{0}正在开机", this.Name);
        }

        public void Usb1()
        {
            this.usb1.Write();
            this.usb1.Read();
        }
        public void Usb2()
        {
            this.usb2.Write();
            this.usb2.Read();
        }
        public void Shutdown()
        {
            Console.WriteLine("{0}正在关机", this.Name);
        }
    }
}
